//
//  FindViewController.m
//  xxShare
//
//  Created by 柳麟喆 on 2018/3/5.
//  Copyright © 2018年 lzLiu. All rights reserved.
//

#import "FindViewController.h"
#import "FeedViewController.h"
#import "HotViewController.h"
#import "SearchViewController.h"
#import "LZSegmentView.h"
#import "FeedModel.h"

@interface FindViewController ()


@end

@implementation FindViewController


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.parentViewController.navigationController.navigationBarHidden = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"热门";
    [self setUp];
}

- (void)setUp{
    self.view.backgroundColor = BACKGROUND_COLOR;
    //添加搜索按钮
    UIBarButtonItem *searchBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"search16.png"] style:(UIBarButtonItemStylePlain) target:self action:@selector(searchBtnClicked)];
    self.navigationItem.leftBarButtonItem = searchBtn;
    
    NSMutableArray *vcArray = [[NSMutableArray alloc]init];
    HotViewController *hot = [[HotViewController alloc]init];
    hot.title = @"推荐";
    [vcArray addObject:hot];
    [self addChildViewController:hot];
    NSArray *findArray=  @[@"美食",@"风景",@"萌宠",@"动漫",@"军事"];
    NSDictionary *dic1 = @{@"imageName":@"avator2.png",
                           @"name":@"叮当猫",
                           @"devote":@"42",
                           @"photos":@[@"美食1",@"美食2",@"美食3",@"美食4"],
                           @"postContent":@"肚子好饿，我的口袋去哪里了？？？",
                           @"location":@"宁波市",
                           @"time":@"7小时前",
                           @"moneyNum":@"53",
                           @"thumbNum":@"109",
                           @"commentNum":@"10",
                           @"tags":@"美食",
                           };
    
      NSDictionary *dic2 = @{@"imageName":@"avator3.png",
                    @"name":@"哪吒",
                    @"devote":@"47",
                    @"photos":@[@"风景1",@"风景2",@"风景3",@"风景4",@"风景5",@"风景6",@"风景7",@"风景8",@"风景9"],
                    @"postContent":@"好想去这些地方！！！",
                    @"location":@"北京天安门广场",
                    @"time":@"昨天",
                    @"moneyNum":@"93",
                    @"thumbNum":@"199",
                    @"commentNum":@"29",
                    @"tags":@"风景",
                    };
    NSDictionary *dic3 = @{@"imageName":@"avator5.png",
                          @"name":@"可达鸭",
                          @"devote":@"79",
                          @"photos":@[@"萌宠1",@"萌宠2",@"萌宠3",@"萌宠4",@"萌宠5",@"萌宠6"],
                          @"postContent":@"好可爱",
                          @"location":@"海口市",
                          @"time":@"2018-3-29 14:21",
                          @"moneyNum":@"66",
                          @"thumbNum":@"201",
                          @"commentNum":@"101",
                          @"tags":@"萌宠",
                          };
    NSDictionary *dic4 = @{@"imageName":@"avator1.png",
                            @"name":@"胖虎",
                            @"devote":@"30",
                            @"photos":@[@"动漫1",@"动漫2",@"动漫3",@"动漫4",@"动漫5"],
                            @"postContent":@"给大家分享下我喜爱的动漫人物😄",
                            @"location":@"杭州市",
                            @"time":@"1小时前",
                            @"moneyNum":@"23",
                            @"thumbNum":@"97",
                            @"commentNum":@"4",
                            @"tags":@"动漫",
                            };
    NSDictionary *dic5 = @{@"imageName":@"avator4.png",
                          @"name":@"球球",
                          @"devote":@"27",
                          @"photos":@[@"军事1",@"军事2",@"军事3",@"军事4",@"军事5"],
                          @"postContent":@"国家越来越强大了。",
                          @"location":@"杭州市西溪湿地",
                          @"time":@"三天前",
                          @"moneyNum":@"153",
                          @"thumbNum":@"309",
                          @"commentNum":@"98",
                          @"tags":@"军事",
                          };
    NSArray *dicArr = @[dic1,dic2,dic3,dic4,dic5];
    for (int i = 0; i < findArray.count; i++) {
        FeedModel *model = [[FeedModel alloc]initWithFeedModel:dicArr[i]];
        FeedViewController *feed = [[FeedViewController alloc]init];
        feed.title = findArray[i];
        [feed.testData insertObject:model atIndex:0];
        [feed.tableview reloadData];
        [vcArray addObject:feed];
        [self addChildViewController:feed];
    }
    
    LZSegmentView *segment = [[LZSegmentView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64 -44) andControllers:vcArray];
    [self.view addSubview:segment];
}

- (void)searchBtnClicked{
    SearchViewController *searchVC = [[SearchViewController alloc]init];
    searchVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:searchVC animated:YES];
}

@end
